const Base = require("../base.js");
const txyoss = require("../public/txyoss");
const puppeteer = require("puppeteer");
// 缃戦〉鏁村睆鎴浘
module.exports = class extends Base {
  async indexAction() {
    const width = parseInt(this.get("pageWidth")) || 1920;
    const height = parseInt(this.get("pageHeight")) || 937;
    const browser = await puppeteer.launch({
	args: ["--no-sandbox", "--disable-setuid-sandbox"],
      defaultViewport: {
        width: width,
        height,
      },
    });
    const fileName = "example.png";
    const page = await browser.newPage();
    await page.goto(this.get("url"));
    const jnnse = await page.screenshot({ path: fileName, fullPage: true });
    let imgurl = await txyoss.upbuff(jnnse, "ysjpg", ".png");
    await browser.close();
    this.success(imgurl);
  }
};
